package com.shenzhen.horselive.utils;

import android.content.Context;
import android.util.Log;
import android.webkit.JavascriptInterface;
import android.widget.Toast;

import com.shenzhen.horselive.beans.ApplyCardBean;
import com.shenzhen.horselive.ui.activity.ApplyOpenCardActivity;

import org.json.JSONException;
import org.json.JSONObject;

public class JsBridger {
   private  Context  context;
   private ApplyCardBean.DataBean dataBean;

    public JsBridger(Context context,ApplyCardBean.DataBean dataBean) {
        this.context = context;
        this.dataBean =dataBean;
    }
    //跳转的方法
    @JavascriptInterface
    public void postInfo(String data)
    {
        try {
            JSONObject  jsonObject =  new JSONObject(data);
//            {"schemeId":"5","schemeTitle":"这里是套餐名称12344"}
            Log.v("data",data);
            if (jsonObject.has("schemeId"))
            {
               String  id  = jsonObject.getString("schemeId");
                if (id.equals(dataBean.getId()+""))
                {
                    ApplyOpenCardActivity.start(context,dataBean);
                }
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
